#ifndef __VO_IMPL_H__
#define __VO_IMPL_H__

#include "includes.h"
#include "sys_impl.h"

#ifdef __cplusplus
extern "C"{
#endif

#define VO_DEV_MAX_NUM 7
#define VO_VIDEO_LAYER_MAX_NUM 7

#if 1
//本MPP中 VO layer都是合成的，这里主要是为了与hisi有个对应
#define VO_DEV_DHD0 0
#define VO_DEV_DHD1 1
#define VO_DEV_DSD0 2

#define VO_VIRT_DEV_0 3
#define VO_VIRT_DEV_1 4
#define VO_VIRT_DEV_2 5
#define VO_VIRT_DEV_3 6
#endif

typedef struct stMPP_VO_CHANNEL_S
{
    BOOL bEnable;
    int32_t s32ChnId;
    BOOL bVisable;

    uint32_t u32FrameRate;
    uint32_t u32Priority;
    RECT_S stRect;
    BOOL bDeflicker;

    //保存上一次显示的帧
    //void *frame;
#ifdef USE_SBUFFER
    //缓冲区最大帧数
    uint32_t u32Depth;
    //sbuffer可以使用，因为是单写单读
    //struct list_head stBufferList;
    SBUFFER stSBuffer;
#endif

    void *pReversePtr;
} MPP_VO_CHANNEL_S;

typedef struct stMPP_VO_VIDEO_LAYER_S
{
    BOOL bEnable;
    VO_LAYER voLayerId;

    RECT_S stDispRect;
    SIZE_S stImageSize;
    uint32_t u32FrameRate;
    PIXEL_FORMAT_E enPixelFormat;

    ANativeWindow *pSurface;

    //用于记录对应的surface指定缓冲区，对应的的通道是否已经绘制了的标志
    //frame_buffer_chn_flags?

    //vvo使用下面的stSBuffer作为输出缓冲，使用一个非显示的surface也是可以的？可以跟普通vo操作方法一致
    //uint32_t u32Depth;
    //sbuffer可以使用，因为是单写单读
    //struct list_head stBufferList;
    //SBUFFER stSBuffer;

    int32_t s32MaxChnNum;
    MPP_VO_CHANNEL_S *pstChannels;

    uint32_t u32BgColor; //背景色 ARGB8888
    void *pstBgImage; //背景图像

    PIN_DATA_S stPinData;

    void *pReversePtr;
} MPP_VO_VIDEO_LAYER_S;

typedef struct stMPP_VO_DEVICE_S
{
    BOOL bEnable;
    VO_PUB_ATTR_S stAttr;
    MPP_VO_VIDEO_LAYER_S *pLayers[VO_VIDEO_LAYER_MAX_NUM];
} MPP_VO_DEVICE_S;

typedef struct stMPP_VO_CONTEXT_S
{
    int32_t quit;
    int32_t s32Ref;
    pthread_mutex_t stMutex;
    pthread_t threadId;
} MPP_VO_CONTEXT_S;

int32_t TR_VO_Module_Init();
int32_t TR_VO_Module_DeInit();

int TR_VO_VideoLayer_Get_Buffer(VO_LAYER VoLayer, AHardwareBuffer **buffer);
int TR_VO_VideoLayer_Put_Buffer(VO_LAYER VoLayer, AHardwareBuffer *buffer);

#ifdef __cplusplus
}
#endif

#endif